from time import sleep

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By


def Auto_eventCheck():
    chrome = webdriver.Chrome()
    chrome.get("http://172.16.55.125:50042")
    chrome.maximize_window()
    chrome.implicitly_wait(3)
    # chrome.find_element(By.XPATH, "//input[@placeholder='请输入用户名称']").send_keys("yunweizhuguan")
    # chrome.find_element(By.XPATH, "//input[@placeholder='请输入密码']").send_keys("123asd!@#$")
    # chrome.find_element(By.XPATH, "//form[@class='form']/input[@placeholder='请输入用户名称']").send_keys("yunweizhuguan")
    chrome.find_element(By.XPATH, '//*[@id="login-page"]/div[5]/form[1]/div[1]/input').send_keys('yunweizhuguan')
    chrome.find_element(By.XPATH, '//*[@id="login-page"]/div[5]/form[1]/div[2]/input').send_keys('123asd!@#$')
    sleep(1)
    chrome.find_element(By.XPATH, '//button[@type="button"]').click()  # 登录
    sleep(2)
    chrome.find_element(By.XPATH, '//*[@id="app"]/div/div[1]/div/div[3]/div/div/a').click()  # 退出大屏
    event = chrome.find_element(By.XPATH, '//*[@id="layout-header"]/div[2]/div[3]')  # 事件管理中心
    ActionChains(chrome).click(event).perform()
    event1 = chrome.find_element(By.XPATH, '//*[@id="layout-menu"]/div[1]/ul/li/div/li')  # 核查处置管理
    ActionChains(chrome).click(event1).perform()
    chrome.find_element(By.XPATH, '//*[@id="layout-menu"]/div[1]/ul/li/ul/li[1]').click()  # 事件核查处置
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[1]/div[2]/div/div').click()  # 日期选择
    sleep(1)
    chrome.find_element(By.CSS_SELECTOR, 'body > div.date-picker--popper-dialog > div.date-picker--popper-body > div.date-picker--shortcuts > span:nth-child(7)').click()# 近一年
    chrome.find_element(By.XPATH, '//*[@id="layout-menu"]/div[1]/ul/li/ul/li[1]').click()  # 点击事件核查处置  消除时间选择框
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[2]/div/div/div[1]/div/div/div[2]').click()  # 已核查事件

    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[3]/div').click()  # 事件类型框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="配置合规性"]').click()
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[3]/div').click()  # 事件类型框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="网络安全异常"]').click()
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/button').click() # 重置按钮
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[1]/div[2]/div/div').click()  # 日期选择
    sleep(1)
    chrome.find_element(By.CSS_SELECTOR, 'body > div.date-picker--popper-dialog > div.date-picker--popper-body > div.date-picker--shortcuts > span:nth-child(7)').click()# 近一年
    chrome.find_element(By.XPATH, '//*[@id="layout-menu"]/div[1]/ul/li/ul/li[1]').click() # 点击事件核查处置  消除时间选择框
    sleep(1)

    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[4]').click()  # 督促状态框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="已督促"]').click()
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[4]').click()  # 督促状态框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="未督促"]').click()
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[4]').click()  # 督促状态框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="全部"]').click()

    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div').click() # 所在部门框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="业务部"]').click()
    sleep(3)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div').click() # 所在部门框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="管理部门"]').click()
    sleep(3)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[1]/div').click() # 所在部门框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="全部"]').click()
    sleep(1)

    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[2]/input').send_keys('网络中')
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/button').click() # 重置按钮
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[1]/div[2]/div/div').click()  # 日期选择
    sleep(1)
    chrome.find_element(By.CSS_SELECTOR, 'body > div.date-picker--popper-dialog > div.date-picker--popper-body > div.date-picker--shortcuts > span:nth-child(7)').click()# 近一年
    chrome.find_element(By.XPATH, '//*[@id="layout-menu"]/div[1]/ul/li/ul/li[1]').click() # 点击事件核查处置  消除时间选择框
    sleep(1)

    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[3]/input').send_keys('终端责任人1')
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[3]/input').clear()
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[3]/input').send_keys('终端责任人3')
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/button').click() # 重置按钮
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/div[1]/div[2]/div/div').click()  # 日期选择
    sleep(1)
    chrome.find_element(By.CSS_SELECTOR, 'body > div.date-picker--popper-dialog > div.date-picker--popper-body > div.date-picker--shortcuts > span:nth-child(7)').click()# 近一年
    chrome.find_element(By.XPATH, '//*[@id="layout-menu"]/div[1]/ul/li/ul/li[1]').click() # 点击事件核查处置  消除时间选择框

    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div').click() # 处置时限框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="24小时"]').click()
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div').click() # 处置时限框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="72小时"]').click()
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[4]/div').click() # 处置时限框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="不限"]').click()
    sleep(1)

    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[5]/div').click() # 督促来源框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="手动督促"]').click()
    sleep(5)
    chrome.find_element(By.XPATH, '//*[@id="main-layout"]/div[3]/div[1]/div/div/div[2]/div/div[1]/div/div[2]/div[5]/div').click() # 督促来源框定位
    chrome.find_element(By.XPATH, '//li[@class="el-select-dropdown__item"]/span[text()="自动督促"]').click()
    sleep(5)


if __name__ == "__main__":
    Auto_eventCheck()
